
#pragma once

#include "cocos2d.h"
USING_NS_CC;


#include "assert.h"
#include <string>
#include <vector>

using namespace std;

static const float MOVEMENT_THRESHOLD = 5.0f;
static const int SOLDIERS_PER_FLAG = 3;

enum class BulletType {
	slash,
	blunt,
	piercing,
	explosion,
	fire,
	ice,
	lightning,
	poison,
	dark,
	holy,
	count
};

struct BulletAttribute {
	int uid;    // hero id
	int tid;    // tower id
	int eid;    // enemy id

	float damage;
	BulletType type;
	Point speed;
	float range;
	float duration;

	BulletAttribute() {
		memset(this, 0, sizeof(this));
	}
};

enum class UnitType {
	ground,
	air,
	water,
	underground,
	count    
};

enum class UnitFaction {
	soldier,
	hero,
	enemy, 
	neutrality,
	count
};

static const char* SOLDIER_TYPE_NAMES[] = {"swordsman", "archer", "alchemist", "miner"};

enum class SoldierType {
	swordsman,
	archer,
	alchemist,
	miner,
	count
};

enum class HeroType {
	paladin,
	barbarian,
	wizard,
	druid,
	engineer,
	count
};

enum class UnitState {
	birth,
	stand,
	walk_to_flag,
	head_to_fight,
	walk_to_mining,
	back_to_camp,
	search,
	melee,
	shoot,
	cast,
	reload,
	dying,
	died,
	escaped,
	freeze,
	work,
	dizzy,
	count
};

enum class AttackRange {
	melee,
	ranged,
	none,
	count
};

enum class MultiTargetType {
	single,
	multiple,
	count
};

enum class TowerType {
	castle,
	rally_point,
	mine,
	special,

	tt_count,
};

enum class SpecialTowerType {
	missile,
	gunner,
	machine_gun,
	holy_burst,
	count
};

struct EnemyInfo{
	float delay;
	string unitName;
	int level;
	int wayIndex;
	int nextWaypointIndex;
	Point birthPos;

	EnemyInfo() {
		memset(this, 0, sizeof(this));
	}
};

struct WayInfo {
	vector<Point> waypoints;
	vector<float> arrRestDistance;
	int acrossInPoint;
	int acrossOutPoint;

	WayInfo() {
		acrossInPoint = -1;
		acrossOutPoint = -1;
	}
};

struct UnitPositionInfo {
	int wayIndex;
	int wayPointIndex;
	Point location;

	UnitPositionInfo() {
		memset(this, 0, sizeof(this));
	}

	UnitPositionInfo(int i, int j, const Point& pos) {
		wayIndex = i;
		wayPointIndex = j;
		location = pos;
	}
};

struct WaveInfo{
	float delay;
	bool hasBoss;
	bool hasAir;
	bool hasNavy;

	Point flagPoint;
	Point startPos;
	vector<EnemyInfo> enemies;

	WaveInfo() {
		memset(this, 0, sizeof(this));
	}
};

struct UnitInfo {
	string key;
	int level;
	float x;
	float y;
	float hp;
	float damage;
	float duration;
	float chance;

	UnitInfo() {
		memset(&x, 0, sizeof(UnitInfo) - sizeof(string));
	}
};

struct PortalInfo {
	int index;
	Point position;
	int ways[5];
	int wayCount;

	PortalInfo() {
		memset(this, 0, sizeof(PortalInfo));
		ways[0] = ways[1] = ways[2] = ways[3] = ways[4] = -1;
	}
};

enum class FlagColor {
	blue,
	teal,
	orange,
	purple,
	red,
	skyblue,
	yellow,
	count
};

struct AnimationInfo{
	string key;
	float frameRate;
	vector<string> frames;

	AnimationInfo() {
		frameRate = 0;
	}
};

struct AchievementInfo {
	string key;
	string title;
	string text;
	int bonus;
	int current;
	int request;

	AchievementInfo() {
		bonus = 0;
		current = 0;
		request = 0;
	}

	AchievementInfo(const string& k, const string& t, const string& c, int n, int cur, int req) {
		key = k;
		title = t;
		text = c;
		bonus = n;

		current = cur;
		request = req;
	}
};

